﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FallDown
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] matrix = new int[8,8];
            for (int i = 0; i < 8; i++)
            {
                int inputNumber = int.Parse(Console.ReadLine());
                for (int j = 0; j < 8; j++)
                {
                    matrix[i, 7-j] = (inputNumber & (1 << j))!=0?1:0;
                }
            }
            //for (int i = 0; i < 8; i++)
            //{
            //    for (int j = 0; j < 8; j++)
            //    {
            //        Console.Write(matrix[i, j]);
            //    }
            //    Console.WriteLine();
            //}
            //Console.WriteLine("--------");
            for (int j = 7; j>=0; j--)
            {
                for (int i = 6; i >= 0; i--)
                {
                    if (matrix[i,j]==1)
                    {
                        int currentPos = i;
                        while ( currentPos <7 &&matrix[currentPos+1,j] ==0 )
                        {
                            matrix[currentPos, j] = 0;
                            matrix[currentPos + 1, j] = 1;
                            currentPos++;
                        }
                    }
                }
            }
            //for (int i = 0; i < 8; i++)
            //{
            //    for (int j = 0; j < 8; j++)
            //    {
            //        Console.Write(matrix[i, j]);
            //    }
            //    Console.WriteLine();
            //}
            for (int i = 0; i < 8; i++)
            {
                int outputNumber = 0;
                for (int j = 0; j < 8; j++)
                {
                    if (matrix[i,j]==1)
                    {
                        outputNumber = outputNumber + (1 << 7-j);   
                    }
                    else
                    {
                        outputNumber = outputNumber + (0 << 7-j);
                    }
                }
                Console.WriteLine(outputNumber);
            }
        }
    }
}
